package com.google.code.wicket.auth.component.marker;

import java.util.Collection;

import org.apache.wicket.Component;

/**
 * Strategy to mark invalid components and then handle such components.
 * 
 * @param <T>
 */
public interface Marker<T> {

    /**
     * Handle an invalid component, usually using
     * {@link Component#getMetaData(org.apache.wicket.MetaDataKey)
     * Component.getMetaData(...)}. Return true if the component was
     * successfully handled (false will give other strategies a shot).
     * 
     * @param component
     * @return true if component was successfully handled
     */
    boolean handleComponent(Component component);

    /**
     * Mark a component as invalid (usually using
     * {@link Component#setMetaData(org.apache.wicket.MetaDataKey, Object)
     * Component.setMetaData(...)}.
     * 
     * @param component
     * @param missingValues
     */
    void mark(Component component, Collection<T> missingValues);

    /**
     * Mark a component type as invalid. Be careful to restrict the logic to the
     * current user / session unless you know what you are doing.
     * 
     * @param componentClass
     * @param missingValues
     */
    void markType(Class<? extends Component> componentClass,
            Collection<T> missingValues);

}
